//new 与delete
#include <iostream>
using namespace std;

class A
{
    int x;
public:
    A(int x = 0):x(x){cout << "构造A(" <<x <<")" <<endl;}
    ~A(){cout << "析构A(" << x << ")" << endl;}
};

int main(int argc, char const *argv[])
{
    //直接定义栈内存对象
    // A a;
    // A b(100);


    //使用new定义动态内存对象，堆内存
    A *p1 = new A;
    A *p2 = new A(200);
    A *p3 = new A[3];

    delete p1;
    delete p2;
    delete [] p3;

    //A *p3 = (A *)malloc(sizeof(A));//仅分配内存

    return 0;
}
